//
//  RBDZButton.m
//  rubaoduanzi
//
//  Created by 李云飞 on 16/9/13.
//  Copyright © 2016年 liyunfei. All rights reserved.
//

#import "RBDZButton.h"

@implementation RBDZButton
+(UIBarButtonItem *)barButtonItemWith:(UIButton *)button andTarget:(id)controller action:(SEL)selector andImageName:(NSString *)imageName andHightlightImage:(NSString *)hightlightImage{
    //添加监听方法
    [button addTarget:controller action:selector forControlEvents:UIControlEventTouchUpInside];
    //设置按钮未选中图片
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal]; 
    //设置图片选中状态下的图片
    [button setImage:[UIImage imageNamed:hightlightImage] forState:UIControlStateHighlighted];
    [button sizeToFit];//自动适应大小
    UIBarButtonItem *item=[[UIBarButtonItem alloc]initWithCustomView:button];
    return item;
}





@end
